package com.example.musicwebcon.model;



import jakarta.persistence.*;

// 指定表名
@Table(name = "user")
@Entity
public class User {

    // @Id 声明主键的配置
    // 使用 String 类型来匹配 SQL 中的 char(10)
    @Id
    @Column(name = "user_id", length = 10, nullable = false)
    private String id;  // SQL 中的 char(10)

    @Column(name = "user_name", length = 50, nullable = false,unique = true)
    private String name;         //用于登录显示,唯一

    @Column(name = "user_password", length = 20, nullable = false)
    private String password;

    @Column(name = "email", unique = true, nullable = false, length = 50)
    private String email;

    @Column(name = "phone", unique = true, nullable = false, length = 11)
    private String phone;

    @Column(name = "nickname", length = 50, nullable = false)
    private String nickname;               //昵称，一般用于社交

    @Enumerated(EnumType.STRING)
    @Column(name = "gender", nullable = false, columnDefinition = "ENUM('男','女','未知') DEFAULT '未知'")
    private Gender gender ;

    @Column(name = "age", nullable = false, columnDefinition = "INT DEFAULT 18")
    private Integer age;

    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getPassword() {
        return password;
    }
    public void setPassword(String password) {
        this.password = password;
    }
    public String getEmail() {
        return email;
    }
    public void setEmail(String email) {
        this.email = email;
    }
    public String getPhone() {
        return phone;
    }
    public void setPhone(String phone) {
        this.phone = phone;
    }
    public String getNickname() {
        return nickname;
    }
    public void setNickname(String nickname) {
        this.nickname = nickname;
    }
    public Gender getGender() {
        return gender;
    }
    public void setGender(Gender gender) {
        this.gender = gender;
    }
    public Integer getAge() {
        return age;
    }
    public void setAge(Integer age) {
        this.age = age;
    }

    // 定义性别的枚举类型
    public enum Gender {
        男,
        女,
        未知
    }

    public String toString() {
        return "User{" +
                "id='" + id + '\'' +
                ", name='" + name + '\'' +
                ", password='" + password + '\'' +
                ", email='" + email + '\'' +
                ", phone='" + phone + '\'' +
                ", nickname='" + nickname + '\'' +
                ", gender=" + gender +
                ", age=" + age +
                '}';
    }
}
